let app = new Vue({
    el:"#app",
    data:{
        username: '',
        password: '',
        repassword: '',
        telephone: '',
        message: ''
    },
    methods:{
        register:function () {
            console.log('Submit......');
            let form = new FormData();
            form.append("userName", this.username);
            form.append("password", this.password);
            form.append("repassword",this.repassword);
            form.append("telephone",this.telephone);
            console.log(form);
            if (this.password != this.repassword) {
                alert("密码不一致!");
                this.message = "确认密码不一致!";
                return;
            }
            axios.post("/register",form).then(function (response) {
                if (response.success=true) {
                    console.log("注册成功!");
                    console.log(response.data);
                    location.href = "/views/login";
                } else {
                    console.log(response.data);
                    app.message = response.data;
                }
            })
                .catch(function (error) {
                        console.log("手机号已经被注册!");
                        alert("手机号已经被注册!");
                        this.message = "手机号已经被注册!";
                });
        }
    }
})